<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/WEB-INF/templates/BasicTemplate.xhtml">

	<ui:define name="content">

		<div class="title ui-widget-header ui-corner-all">
			<h:panelGrid style="margin:auto;">
		BUSCAR SESIONES
		</h:panelGrid>

		</div>

		<h:form id="formSearch">

			<h:panelGrid style="margin:auto;">

				<h:panelGrid style="margin:auto;text-align:center;">
					<p:messages id="messages"></p:messages>
				</h:panelGrid>

				<h:panelGrid columns="2">
					<p:outputLabel value="Fecha"></p:outputLabel>
					<p:calendar pattern="dd-MM-yyyy"
						value="#{sessionController.startedAt}" required="true"
						requiredMessage="Debe seleccionar fecha"></p:calendar>
				</h:panelGrid>


				<h:panelGrid columns="3" style="margin:auto;text-align:center;">
					<p:commandButton icon="ui-icon-search"
						actionListener="#{sessionController.searchAgentSessions}"
						value="Buscar" process="@form"
						update=":formSearch:searchTable :formSearch:messages">
					</p:commandButton>

				</h:panelGrid>

			</h:panelGrid>

			<p:dataTable value="#{sessionController.sessions}" var="s"
				rowKey="#{s.id}" paginator="true" rows="10" id="searchTable"
				selectionMode="single">


				<p:column headerText="Campaña" sortBy="#{s.campaign.name}">
					<h:outputText value="#{s.campaign.name}"></h:outputText>
				</p:column>

				<p:column headerText="Tipo" sortBy="#{s.sessionType.name}">
					<h:outputText value="#{s.sessionType.name}"></h:outputText>
				</p:column>

				<p:column headerText="Inicio" sortBy="#{s.startedAt}">
					<h:outputText value="#{s.startedAt}">
						<f:convertDateTime pattern="dd-MM-yyyy HH:mm:ss"
							timeZone="America/Lima" />
					</h:outputText>
				</p:column>

				<p:column headerText="Fin" sortBy="#{s.endedAt}">
					<h:outputText value="#{s.endedAt}">
						<f:convertDateTime pattern="dd-MM-yyyy HH:mm:ss"
							timeZone="America/Lima" />
					</h:outputText>
				</p:column>
				<p:column headerText="Duración" sortBy="#{s.endedAtTempury}">
					<h:outputText value="#{s.endedAtTempury}">
					</h:outputText>
				</p:column>

			</p:dataTable>


		</h:form>
	</ui:define>

</ui:composition>
</html>
